package com.suxin.splitter.merger;

import com.google.common.reflect.TypeToken;
import org.checkerframework.checker.units.qual.A;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * @author Tang
 * @classname AbstractFixTypeResultMerger
 * @description [  ]
 * @date 2022/11/8 19:09
 */
public abstract class AbstractFixTypeResultMerger<R>
        extends AbstractResultMerger<R>
        implements SmartResultMerger<R>{

    private final Class supportType;

    public AbstractFixTypeResultMerger() {
        TypeToken<R> rTypeToken = new TypeToken<R>(getClass()){
        };
        this.supportType = rTypeToken.getRawType();

        TypeToken1<String> token = new TypeToken1<String>(){};
        ParameterizedType type = (ParameterizedType) token.getClass().getGenericSuperclass();
        System.out.println((Type)(type.getActualTypeArguments()[0]));
    }

    @Override
    public boolean support(Class<R> resultType) {
        return this.supportType.isAssignableFrom(resultType);
    }

    public static void main(String[] args) {
        AbstractFixTypeResultMerger<String> merger = new AbstractFixTypeResultMerger<String>(){};
    }


    class TypeToken1<T> {

    }

}

